package cn.fl.project.controller;

import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.condition.SysEmpBankAccQueryCondition;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.utils.*;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.project.condition.PrjRbtbillBscInfoQueryCondition;
import cn.fl.project.service.IPrjRbtbillApplyService;
import cn.fl.project.service.IPrjRbtbillBscInfoService;
import cn.fl.project.vo.PrjRbtbillApplyVO;
import cn.fl.project.vo.PrjRbtbillBscInfoVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysEmpBankAccService;
import cn.fl.system.vo.SysEmpBankAccVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Description: 返利票据基础信息表 控制层
 */
@Controller
@RequestMapping("/project/prjRbtbillBscInfo")
public class PrjRbtbillBscInfoController extends BaseController {
    private static final Logger logger = LoggerFactory.getLogger(PrjRbtbillBscInfoController.class);

    /**
     * PrjRbtbillBscInfo 服务层BEAN
     */
    @Autowired
    private IPrjRbtbillBscInfoService prjRbtbillBscInfoService;
    /**
     * PrjRbtbillApply 服务层BEAN
     */
    @Autowired
    private IPrjRbtbillApplyService prjRbtbillApplyService;
    /**
     * SysEmpBankAcc 服务层BEAN
     */
    @Autowired
    private ISysEmpBankAccService sysEmpBankAccService;

    //-------------------------------------------------------------------begin

    /**
     * 初始化 申请列表（带分页）
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/getApplyListPage.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getApplyListPage(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");

        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        PrjRbtbillBscInfoQueryCondition qc = new PrjRbtbillBscInfoQueryCondition();
        //TODO 设置查询条件？
        String lsDtStart = request.getParameter("lsDtStart");
        if (StringUtils.isNotEmpty(lsDtStart)) {
            qc.setLsDtStart(DateUtils.formatStringToDate(lsDtStart, DateUtils.YYYY_MM_DD));
        }
        String lsDtEnd = request.getParameter("lsDtEnd");
        if (StringUtils.isNotEmpty(lsDtEnd)) {
            qc.setLsDtEnd(DateUtils.formatStringToDate(lsDtEnd, DateUtils.YYYY_MM_DD));
        }
        String applyId = request.getParameter("applyId");
        if (StringUtils.isNotEmpty(applyId)) {
            qc.setApplyId(Long.valueOf(applyId));
        }
        page.setCondition(qc);
        try {
            BaseLogUtils.newLogger("初始化返利报销流程申请页面支付表信息").setKeys("page:" + JSON.toJSONString(page)).info();
            Pager pager = this.prjRbtbillBscInfoService.searchApplyListPage(page);
            List<PrjRbtbillBscInfoVO> list = (List<PrjRbtbillBscInfoVO>) pager.getResultList();
            ListPageVO<PrjRbtbillBscInfoVO> listPage = new ListPageVO<PrjRbtbillBscInfoVO>(list, pager.getTotalCount());
            return listPage;
        } catch (BaseException e) {
            BaseLogUtils.newLogger("初始化返利报销流程申请页面支付表信息异常").setKeys("applyId:" + applyId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
            throw e;
        } catch (Exception e) {
            BaseLogUtils.newLogger("初始化返利报销流程申请页面支付表信息异常").setKeys("applyId:" + applyId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
            throw e;
        }

    }


    /**
     * 初始化 申请列表
     */
    @RequestMapping(value = "/getApplyList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getApplyList(HttpServletRequest request, HttpServletResponse response) {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
        PrjRbtbillBscInfoQueryCondition qc = new PrjRbtbillBscInfoQueryCondition();
        String lsDtStart = request.getParameter("lsDtStart");
        if (StringUtils.isNotEmpty(lsDtStart)) {
            qc.setLsDtStart(DateUtils.formatStringToDate(lsDtStart, DateUtils.YYYY_MM_DD));
        }
        String lsDtEnd = request.getParameter("lsDtEnd");
        if (StringUtils.isNotEmpty(lsDtEnd)) {
            qc.setLsDtEnd(DateUtils.formatStringToDate(lsDtEnd, DateUtils.YYYY_MM_DD));
        }
        BaseLogUtils.info(logger, "getApplyList", "getApplyList页面数据.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
        List<PrjRbtbillBscInfoVO> list = new ArrayList<PrjRbtbillBscInfoVO>();
        try {
            list = this.prjRbtbillBscInfoService.searchApplyList(qc);
            result.setSuccess(BaseConstant.IS_YESNO_YES);
            result.setInfo("请求成功");
            result.setData(list);
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "getApplyList", "prjRbtbillApplyModify页面请求数据失败,DATA:" + JSONObject.toJSONString(qc) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getApplyList", "prjRbtbillApplyModify页面请求数据失败,系统错误.DATA:" + JSONObject.toJSONString(qc) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }


    /**
     * 到列表页面
     */
    @RequestMapping(value = "/toListPage.do", method = {RequestMethod.GET})
    public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPage", "加载PrjRbtbillBscInfo列表页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView view = new ModelAndView("project/prjRbtbillApply/prjRbtbillBscInfoList");
        String applyId = request.getParameter("applyId");
        String version = request.getParameter("version");
        if (StringUtils.isBlank(version)) {
            version = "3";
        }
        //去查询  返利开票申请表 查询申请人id
        PrjRbtbillApplyVO vo = this.prjRbtbillApplyService.selectById(Long.parseLong(applyId));
        if (null != vo) {
            if (vo.getRbtAmt() != null) {
                view.addObject("rbtAmt", DecimalUtils.convertFenToYuan(vo.getRbtAmt()));
            }
            if (vo.getBillAmt() != null) {
                view.addObject("billAmt", DecimalUtils.convertFenToYuan(vo.getBillAmt()));
            }
            if (vo.getBillTpAmt() != null) {
                view.addObject("billTpAmt", DecimalUtils.convertFenToYuan(vo.getBillTpAmt()));
            }
            if (vo.getActualPaymentTm() != null) {
                view.addObject("actualPaymentTm", DateUtils.formatDateToString(vo.getActualPaymentTm(), DateUtils.YYYY_MM_DD));
            }
            if (vo.getActualPaymentAmt() != null) {
                view.addObject("actualPaymentAmt", DecimalUtils.convertFenToYuan(vo.getActualPaymentAmt()));
            }

            view.addObject("accNo", vo.getAccNo());//收款账号
            view.addObject("rcptUnt", vo.getRcptUnt());//收款人姓名
            view.addObject("bkNm", vo.getBkNm());//开户银行
            view.addObject("bkNo", vo.getBkNo());//开户行号
            //兼容历史数据
            if (StringUtils.isBlank(vo.getRcptUnt()) && StringUtils.isBlank(vo.getAccNo())) {
                SysEmpBankAccQueryCondition sysEmpBankAccQueryCondition = new SysEmpBankAccQueryCondition();
                sysEmpBankAccQueryCondition.setUsrId(vo.getApplyMgrId());
                List<SysEmpBankAccVO> selectEmpBankList = sysEmpBankAccService.selectEmpBankList(sysEmpBankAccQueryCondition);//去查询当前用户的银行卡数据
                if (CollectionUtils.isNotEmpty(selectEmpBankList)) {
                    SysEmpBankAccVO bankAccVO = selectEmpBankList.get(selectEmpBankList.size() - 1);
                    view.addObject("bkid", bankAccVO.getId());//唯一标识
                    view.addObject("accNo", bankAccVO.getAccNo());//收款账号
                    view.addObject("rcptUnt", bankAccVO.getRcptUnt());//收款人姓名
                    view.addObject("bkNm", bankAccVO.getBkNm());//开户银行
                    view.addObject("bkNo", bankAccVO.getBkNo());//开户行号
                }
            }
        }
        view.addObject("applyId", applyId);
        view.addObject("version", version);
        return view;
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initPrjRbtbillBscInfoList(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        PrjRbtbillBscInfoQueryCondition qc = new PrjRbtbillBscInfoQueryCondition();
        //设置查询条件
        String applyId = request.getParameter("applyId");
        if (StringUtils.isNotEmpty(applyId)) {
            qc.setApplyId(Long.valueOf(applyId));
        }
        String paySchNo = request.getParameter("paySchNo");
        if (StringUtils.isNotEmpty(paySchNo)) {
            qc.setPaySchNo(paySchNo);
        }
        qc.setBillStsCd("1");//1正常2作废
        page.setCondition(qc);
        try {
            BaseLogUtils.newLogger("初始化返利报销流程附加页面支付表信息").setKeys("page:" + JSON.toJSONString(page)).info();
            Pager pager = this.prjRbtbillBscInfoService.searchListPage(page);
            List<PrjRbtbillBscInfoVO> list = (List<PrjRbtbillBscInfoVO>) pager.getResultList();
            ListPageVO<PrjRbtbillBscInfoVO> listPage = new ListPageVO<PrjRbtbillBscInfoVO>(list, pager.getTotalCount());
            return listPage;
        } catch (BaseException e) {
            BaseLogUtils.newLogger("初始化返利报销流程附加页面支付表信息异常").setKeys("applyId:" + applyId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
            throw e;
        } catch (Exception e) {
            BaseLogUtils.newLogger("初始化返利报销流程附加页面支付表信息异常").setKeys("applyId:" + applyId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
            throw e;
        }

    }

    //-------------------------------------------------------------------end

    /**
     * 到新增页面
     */
    @RequestMapping(value = "/toAddPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toAddPage", "加载PrjRbtbillBscInfo Add页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("project/prjRbtbillApply/prjRbtbillBscInfoModify");
        //this.prepare(request,mav);
        return mav;
    }

    /**
     * 到修改页面
     */
    @RequestMapping(value = "/toModifyPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toModifyPage", "加载PrjRbtbillBscInfo Modify页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("project/prjRbtbillApply/prjRbtbillBscInfoModify");
        //this.prepare(request,mav);

        String id = request.getParameter("id");
        PrjRbtbillBscInfoVO prjRbtbillBscInfoVO = this.prjRbtbillBscInfoService.selectById(Long.valueOf(id));
        mav.addObject("prjRbtbillBscInfoVO", prjRbtbillBscInfoVO);
        return mav;
    }

    //加载数据字典数据、传值等 ？
    public void prepare(HttpServletRequest request, ModelAndView mav) {

    }

    /**
     * 删除数据
     */
    @RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO removePrjRbtbillBscInfoByIds(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String ids = request.getParameter("ids");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
        if (StringUtils.isEmpty(ids)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "removePrjRbtbillBscInfoByIds", "删除PrjRbtbillBscInfo数据,主键参数为空!", CurrentThreadContext.getCurrentUserName());
            return result;
        }

        List<Long> idsList = new ArrayList<Long>();
        JSONArray idsArray = JSONArray.fromObject(ids);
        for (Object object : idsArray) {
            idsList.add(Long.valueOf(object.toString()));
        }

        try {
            boolean success = this.prjRbtbillBscInfoService.removeByIds(idsList);
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
                BaseLogUtils.info(logger, "removePrjRbtbillBscInfoByIds", "删除PrjRbtbillBscInfo数据失败,ID:" + idsList.toString(), CurrentThreadContext.getCurrentUserName());
            }
            BaseLogUtils.info(logger, "removePrjRbtbillBscInfoByIds", "删除PrjRbtbillBscInfo数据成功,ID:" + idsList.toString(), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "removePrjRbtbillBscInfoByIds", "删除PrjRbtbillBscInfo数据失败,ID:" + idsList.toString() + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "removePrjRbtbillBscInfoByIds", "删除PrjRbtbillBscInfo数据失败,系统错误.ID:" + idsList.toString() + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 得到一条记录
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getById.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getPrjRbtbillBscInfoById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "getPrjRbtbillBscInfoById", "获取PrjRbtbillBscInfo数据,主键参数为空.", CurrentThreadContext.getCurrentUserName());
            return result;
        }

        try {
            PrjRbtbillBscInfoVO vo = this.prjRbtbillBscInfoService.selectById(Long.valueOf(id));
            if (null == vo) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
                BaseLogUtils.info(logger, "getPrjRbtbillBscInfoById", "获取PrjRbtbillBscInfo数据不存在,ID:" + id, CurrentThreadContext.getCurrentUserName());
            }
            result.setData(vo);
            BaseLogUtils.info(logger, "getPrjRbtbillBscInfoById", "获取PrjRbtbillBscInfo数据成功,ID:" + id, CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "getPrjRbtbillBscInfoById", "获取PrjRbtbillBscInfo数据失败,ID:" + id + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getPrjRbtbillBscInfoById", "获取PrjRbtbillBscInfo数据失败,系统错误.ID:" + id + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object addPrjRbtbillBscInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
        PrjRbtbillBscInfoVO entity = null;//获取参数
        try {
            entity = this.getRequestParamForPrjRbtbillBscInfo(request);//获取参数
            Long id = this.prjRbtbillBscInfoService.add(entity);
            result.setData(id);
            BaseLogUtils.info(logger, "addPrjRbtbillBscInfo", "新增PrjRbtbillBscInfo数据成功,ID:" + id + ".DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.info(logger, "addPrjRbtbillBscInfo", "新增PrjRbtbillBscInfo数据失败.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.error(logger, "addPrjRbtbillBscInfo", "新增PrjRbtbillBscInfo数据失败,系统错误.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/modify.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modifyPrjRbtbillBscInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
        PrjRbtbillBscInfoVO entity = null;
        try {
            entity = this.getRequestParamForPrjRbtbillBscInfo(request);
            if (entity.getId() == null) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
                BaseLogUtils.info(logger, "modifyPrjRbtbillBscInfo", "修改PrjRbtbillBscInfo信息,主键参数为空！.", CurrentThreadContext.getCurrentUserName());
                return result;
            }

            boolean success = this.prjRbtbillBscInfoService.modify(entity);
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
                BaseLogUtils.info(logger, "modifyPrjRbtbillBscInfo", "修改PrjRbtbillBscInfo数据失败.DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
                return result;
            }
            BaseLogUtils.info(logger, "modifyPrjRbtbillBscInfo", "修改PrjRbtbillBscInfo数据成功.DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.info(logger, "modifyPrjRbtbillBscInfo", "修改PrjRbtbillBscInfo数据失败.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.error(logger, "modifyPrjRbtbillBscInfo", "修改PrjRbtbillBscInfo数据失败,系统错误.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 获取请求参数
     *
     * @param request 请求
     * @return
     */
    @SuppressWarnings("unused")
    private PrjRbtbillBscInfoVO getRequestParamForPrjRbtbillBscInfo(HttpServletRequest request) throws BaseException {
        //获取参数
        String id = request.getParameter("id");//主键
        String applyId = request.getParameter("applyId");//申请ID
        String paySchNo = request.getParameter("paySchNo");//支付表编号
        String paySchId = request.getParameter("paySchId");//支付表ID
        String billTypCd = request.getParameter("billTypCd");//票据类型（PRJ0033）
        String billNo = request.getParameter("billNo");//票据号
        String billStsCd = request.getParameter("billStsCd");//票据状态（SYS0035）
        String splRbtAmt = request.getParameter("splRbtAmt");//经销商返利金额(分)
        String gpsRbtAmt = request.getParameter("gpsRbtAmt");//GPS返利金额(分)
        String capPayId = request.getParameter("capPayId");//付款ID
        String lsDt = request.getParameter("lsDt");//起租日

        //验证参数并赋值
        PrjRbtbillBscInfoVO entity = new PrjRbtbillBscInfoVO();
        //entity.setApplyId(applyId);//申请ID
        //entity.setPaySchNo(paySchNo);//支付表编号
        //entity.setPaySchId(paySchId);//支付表ID
        //entity.setBillTypCd(billTypCd);//票据类型（PRJ0033）
        //entity.setBillNo(billNo);//票据号
        //entity.setBillStsCd(billStsCd);//票据状态（SYS0035）
        //entity.setSplRbtAmt(splRbtAmt);//经销商返利金额(分)
        //entity.setGpsRbtAmt(gpsRbtAmt);//GPS返利金额(分)
        //entity.setCapPayId(capPayId);//付款ID
        //entity.setLsDt(lsDt);//起租日

//		if (StringUtils.isBlank(name)) {
//            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "名称不能为空.");
//      }
//      if (StringUtils.isNotBlank(num)) {
//          if (!StringUtils.isUnsignedNumeric(num)) {
//                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请填写正确的数字.");
//          }
//      }

        Date tm = new Date();
        if (StringUtils.isNotBlank(id)) {
            entity.setId(Long.valueOf(id));
            entity.setMdfTm(tm);
            entity.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
        } else {
            entity.setCrtTm(tm);
            entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
            //entity.setCrtUsrOrgCd(CurrentThreadContext.getCurrentOrgCd());//当前用户组织机构代码
            //entity.setOrgCd(CurrentThreadContext.getCurrentBuOrgCd());//事业部组织机构代码
        }

        return entity;
    }
}

